<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	public $helper;
	
	protected function _initAutoload() {
		
		require_once 'configs/_helper.php';
		$this->helper = new helper();
		
		$autoloader = new Zend_Application_Module_Autoloader(array( 
                    'namespace' => '', 
                    'basePath' => dirname(__FILE__), 
                )); 
                
                
                //var_dump($autoloader);
        return $autoloader; 
	}
	
	protected function _initDB() {
		
		$dbOption = $this->getOption('resources');
		$dbOption = $dbOption['db'];
		
		// Setup database
    	$db = Zend_Db::factory($dbOption['adapter'], $dbOption['params']);
    	$db->setFetchMode(Zend_Db::FETCH_ASSOC);
    	
	    $db->query("SET NAMES 'utf8'");
	    $db->query("SET CHARACTER SET 'utf8'");
	
	    Zend_Registry::set('connectDB', $db);
	
	    //Khi thiet lap che do nay model moi co the su dung duoc
	    Zend_Db_Table::setDefaultAdapter($db);
	
	    // Return it, so that it can be stored by the bootstrap
	    return $db;	
	}
	
	
	
	protected function _initCheckLogin(){
		$auth = Zend_Auth::getInstance();
    	$infoUser = $auth->getIdentity();
    	return (@$infoUser->username);
	}
}

